
public class MyCircularQueue {

    int val[];

    int front;

    int rear;

    int size;

    public MyCircularQueue(int k) {

        val = new int[k];

    }

    public boolean enQueue(int value) {
           if(isFull()) return false;

           val[rear] = value;

           rear = (rear + 1) % val.length;

           size++;

           return true;

    }

    public boolean deQueue() {

        if(isEmpty()) return false;

        front = (front + 1) % val.length;

        size--;

        return true;
    }

    public int Front() {
      if(isEmpty()) return -1;

      return val[front];
    }

    public int Rear() {
       if(isEmpty()) return -1;

       return val[rear];
    }

    public boolean isEmpty() {
           return size == 0;
    }

    public boolean isFull() {
         return !isEmpty() && front == rear;
    }
}
